package com.itheima.list;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class Demo03 {

    public static void main(String[] args) {
        LinkedList<String> list= new LinkedList<>();
        list.add("蔡徐坤");
        list.add("鹿晗");
        list.add("鹿晗");
        list.add("张艺兴");
        list.add("黄子韬");
        list.add("吴签");

        //foreach
        list.forEach(s-> System.out.println(s));
        //for
        for (String s : list) {
            System.out.println(s);
        }
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }

        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }
}
